package com.qianyu.project.web.controller.nyx;

import com.qianyu.project.entity.TechnicalDisclosure;
import com.qianyu.project.entity.WorkOrgPlan;
import com.qianyu.project.service.IWorkLogService;
import com.qianyu.project.service.IWorkOrgPlanService;
import com.qianyu.project.utils.Result;
import com.qianyu.project.utils.ResultTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

@RestController
@RequestMapping("NyxWorOrgPlan")
public class NyxWorOrgPlanController {

    @Autowired
    private IWorkOrgPlanService workOrgPlanService;

    @GetMapping("")
    public Result getList(@RequestParam Map<String,String> map){
        return ResultTool.success(workOrgPlanService.getList(map));
    }

    @DeleteMapping("/{id}")
    public Result del(@PathVariable String id){
        workOrgPlanService.removeByIds(Arrays.asList(id.split(",").clone()));
        return ResultTool.success();
    }

    @GetMapping("/id")
    public Result getId(){
        return ResultTool.success(workOrgPlanService.getId());
    }

    @PostMapping("")
    public Result save(@RequestBody WorkOrgPlan workOrgPlan){
        workOrgPlanService.add(workOrgPlan);
        return  ResultTool.success();
    }

    @PutMapping("")
    public Result update(@RequestBody WorkOrgPlan workOrgPlan){
        System.out.println(workOrgPlan);
        workOrgPlanService.updateWOP(workOrgPlan);
        return  ResultTool.success();
    }

}
